package concurrent.guarded;

import java.util.concurrent.Callable;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ConditionVarBlocker implements Blocker {

    private final Lock lock;
    private final Condition condition;

    public ConditionVarBlocker(Lock lock) {
        this.lock = lock;
        this.condition = lock.newCondition();
    }

    public ConditionVarBlocker() {
        this.lock = new ReentrantLock();
        this.condition = lock.newCondition();
    }

    @Override
    public <V> V callWithGuard(GuardedAction<V> guardedAction) throws Exception {
        lock.lockInterruptibly();
        return null;
    }

    @Override
    public void signalAfter(Callable<Boolean> stateOperation) throws Exception {

    }

    @Override
    public void signal() throws InterruptedException {

    }

    @Override
    public void signalBroadcast(Callable<Boolean> stateOperation) throws Exception {

    }
}
